<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>error.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_fs_error.js.html">error.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2011 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview A wrapper for the HTML5 FileError object.
<a name="line17"></a> *
<a name="line18"></a> */
<a name="line19"></a>
<a name="line20"></a>goog.provide(&#39;goog.fs.Error&#39;);
<a name="line21"></a>goog.provide(&#39;goog.fs.Error.ErrorCode&#39;);
<a name="line22"></a>
<a name="line23"></a>goog.require(&#39;goog.debug.Error&#39;);
<a name="line24"></a>goog.require(&#39;goog.object&#39;);
<a name="line25"></a>goog.require(&#39;goog.string&#39;);
<a name="line26"></a>
<a name="line27"></a>
<a name="line28"></a>
<a name="line29"></a>/**
<a name="line30"></a> * A filesystem error. Since the filesystem API is asynchronous, stack traces
<a name="line31"></a> * are less useful for identifying where errors come from, so this includes a
<a name="line32"></a> * large amount of metadata in the message.
<a name="line33"></a> *
<a name="line34"></a> * @param {!DOMError} error
<a name="line35"></a> * @param {string} action The action being undertaken when the error was raised.
<a name="line36"></a> * @constructor
<a name="line37"></a> * @extends {goog.debug.Error}
<a name="line38"></a> * @final
<a name="line39"></a> */
<a name="line40"></a>goog.fs.Error = function(error, action) {
<a name="line41"></a>  /** @type {string} */
<a name="line42"></a>  this.name;
<a name="line43"></a>
<a name="line44"></a>  /**
<a name="line45"></a>   * @type {goog.fs.Error.ErrorCode}
<a name="line46"></a>   * @deprecated Use the &#39;name&#39; or &#39;message&#39; field instead.
<a name="line47"></a>   */
<a name="line48"></a>  this.code;
<a name="line49"></a>
<a name="line50"></a>  if (goog.isDef(error.name)) {
<a name="line51"></a>    this.name = error.name;
<a name="line52"></a>    // TODO(user): Remove warning suppression after JSCompiler stops
<a name="line53"></a>    // firing a spurious warning here.
<a name="line54"></a>    /** @suppress {deprecated} */
<a name="line55"></a>    this.code = goog.fs.Error.getCodeFromName_(error.name);
<a name="line56"></a>  } else {
<a name="line57"></a>    this.code = error.code;
<a name="line58"></a>    this.name = goog.fs.Error.getNameFromCode_(error.code);
<a name="line59"></a>  }
<a name="line60"></a>  goog.fs.Error.base(this, &#39;constructor&#39;,
<a name="line61"></a>      goog.string.subs(&#39;%s %s&#39;, this.name, action));
<a name="line62"></a>};
<a name="line63"></a>goog.inherits(goog.fs.Error, goog.debug.Error);
<a name="line64"></a>
<a name="line65"></a>
<a name="line66"></a>/**
<a name="line67"></a> * Names of errors that may be thrown by the File API, the File System API, or
<a name="line68"></a> * the File Writer API.
<a name="line69"></a> *
<a name="line70"></a> * @see http://dev.w3.org/2006/webapi/FileAPI/#ErrorAndException
<a name="line71"></a> * @see http://www.w3.org/TR/file-system-api/#definitions
<a name="line72"></a> * @see http://dev.w3.org/2009/dap/file-system/file-writer.html#definitions
<a name="line73"></a> * @enum {string}
<a name="line74"></a> */
<a name="line75"></a>goog.fs.Error.ErrorName = {
<a name="line76"></a>  ABORT: &#39;AbortError&#39;,
<a name="line77"></a>  ENCODING: &#39;EncodingError&#39;,
<a name="line78"></a>  INVALID_MODIFICATION: &#39;InvalidModificationError&#39;,
<a name="line79"></a>  INVALID_STATE: &#39;InvalidStateError&#39;,
<a name="line80"></a>  NOT_FOUND: &#39;NotFoundError&#39;,
<a name="line81"></a>  NOT_READABLE: &#39;NotReadableError&#39;,
<a name="line82"></a>  NO_MODIFICATION_ALLOWED: &#39;NoModificationAllowedError&#39;,
<a name="line83"></a>  PATH_EXISTS: &#39;PathExistsError&#39;,
<a name="line84"></a>  QUOTA_EXCEEDED: &#39;QuotaExceededError&#39;,
<a name="line85"></a>  SECURITY: &#39;SecurityError&#39;,
<a name="line86"></a>  SYNTAX: &#39;SyntaxError&#39;,
<a name="line87"></a>  TYPE_MISMATCH: &#39;TypeMismatchError&#39;
<a name="line88"></a>};
<a name="line89"></a>
<a name="line90"></a>
<a name="line91"></a>/**
<a name="line92"></a> * Error codes for file errors.
<a name="line93"></a> * @see http://www.w3.org/TR/file-system-api/#idl-def-FileException
<a name="line94"></a> *
<a name="line95"></a> * @enum {number}
<a name="line96"></a> * @deprecated Use the &#39;name&#39; or &#39;message&#39; attribute instead.
<a name="line97"></a> */
<a name="line98"></a>goog.fs.Error.ErrorCode = {
<a name="line99"></a>  NOT_FOUND: 1,
<a name="line100"></a>  SECURITY: 2,
<a name="line101"></a>  ABORT: 3,
<a name="line102"></a>  NOT_READABLE: 4,
<a name="line103"></a>  ENCODING: 5,
<a name="line104"></a>  NO_MODIFICATION_ALLOWED: 6,
<a name="line105"></a>  INVALID_STATE: 7,
<a name="line106"></a>  SYNTAX: 8,
<a name="line107"></a>  INVALID_MODIFICATION: 9,
<a name="line108"></a>  QUOTA_EXCEEDED: 10,
<a name="line109"></a>  TYPE_MISMATCH: 11,
<a name="line110"></a>  PATH_EXISTS: 12
<a name="line111"></a>};
<a name="line112"></a>
<a name="line113"></a>
<a name="line114"></a>/**
<a name="line115"></a> * @param {goog.fs.Error.ErrorCode} code
<a name="line116"></a> * @return {string} name
<a name="line117"></a> * @private
<a name="line118"></a> */
<a name="line119"></a>goog.fs.Error.getNameFromCode_ = function(code) {
<a name="line120"></a>  var name = goog.object.findKey(goog.fs.Error.NameToCodeMap_, function(c) {
<a name="line121"></a>    return code == c;
<a name="line122"></a>  });
<a name="line123"></a>  if (!goog.isDef(name)) {
<a name="line124"></a>    throw new Error(&#39;Invalid code: &#39; + code);
<a name="line125"></a>  }
<a name="line126"></a>  return name;
<a name="line127"></a>};
<a name="line128"></a>
<a name="line129"></a>
<a name="line130"></a>/**
<a name="line131"></a> * Returns the code that corresponds to the given name.
<a name="line132"></a> * @param {string} name
<a name="line133"></a> * @return {goog.fs.Error.ErrorCode} code
<a name="line134"></a> * @private
<a name="line135"></a> */
<a name="line136"></a>goog.fs.Error.getCodeFromName_ = function(name) {
<a name="line137"></a>  return goog.fs.Error.NameToCodeMap_[name];
<a name="line138"></a>};
<a name="line139"></a>
<a name="line140"></a>
<a name="line141"></a>/**
<a name="line142"></a> * Mapping from error names to values from the ErrorCode enum.
<a name="line143"></a> * @see http://www.w3.org/TR/file-system-api/#definitions.
<a name="line144"></a> * @private {!Object.&lt;string, goog.fs.Error.ErrorCode&gt;}
<a name="line145"></a> */
<a name="line146"></a>goog.fs.Error.NameToCodeMap_ = goog.object.create(
<a name="line147"></a>    goog.fs.Error.ErrorName.ABORT,
<a name="line148"></a>    goog.fs.Error.ErrorCode.ABORT,
<a name="line149"></a>
<a name="line150"></a>    goog.fs.Error.ErrorName.ENCODING,
<a name="line151"></a>    goog.fs.Error.ErrorCode.ENCODING,
<a name="line152"></a>
<a name="line153"></a>    goog.fs.Error.ErrorName.INVALID_MODIFICATION,
<a name="line154"></a>    goog.fs.Error.ErrorCode.INVALID_MODIFICATION,
<a name="line155"></a>
<a name="line156"></a>    goog.fs.Error.ErrorName.INVALID_STATE,
<a name="line157"></a>    goog.fs.Error.ErrorCode.INVALID_STATE,
<a name="line158"></a>
<a name="line159"></a>    goog.fs.Error.ErrorName.NOT_FOUND,
<a name="line160"></a>    goog.fs.Error.ErrorCode.NOT_FOUND,
<a name="line161"></a>
<a name="line162"></a>    goog.fs.Error.ErrorName.NOT_READABLE,
<a name="line163"></a>    goog.fs.Error.ErrorCode.NOT_READABLE,
<a name="line164"></a>
<a name="line165"></a>    goog.fs.Error.ErrorName.NO_MODIFICATION_ALLOWED,
<a name="line166"></a>    goog.fs.Error.ErrorCode.NO_MODIFICATION_ALLOWED,
<a name="line167"></a>
<a name="line168"></a>    goog.fs.Error.ErrorName.PATH_EXISTS,
<a name="line169"></a>    goog.fs.Error.ErrorCode.PATH_EXISTS,
<a name="line170"></a>
<a name="line171"></a>    goog.fs.Error.ErrorName.QUOTA_EXCEEDED,
<a name="line172"></a>    goog.fs.Error.ErrorCode.QUOTA_EXCEEDED,
<a name="line173"></a>
<a name="line174"></a>    goog.fs.Error.ErrorName.SECURITY,
<a name="line175"></a>    goog.fs.Error.ErrorCode.SECURITY,
<a name="line176"></a>
<a name="line177"></a>    goog.fs.Error.ErrorName.SYNTAX,
<a name="line178"></a>    goog.fs.Error.ErrorCode.SYNTAX,
<a name="line179"></a>
<a name="line180"></a>    goog.fs.Error.ErrorName.TYPE_MISMATCH,
<a name="line181"></a>    goog.fs.Error.ErrorCode.TYPE_MISMATCH);
</pre>


</body>
</html>
